Skip to content

Extract share latency timing tracker out of sv1 and sv2 - #2013

Open
mutatrum wants to merge 10 commits into
bitaxeorg:masterfrom
mutatrum:refactor/unified-stratum-timing
Open

mutatrum wants to merge 10 commits into
bitaxeorg:masterfrom
mutatrum:refactor/unified-stratum-timing

Conversation

@mutatrum

@mutatrum mutatrum commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator

Both SV1 and SV2 had separate share submit timing systems, this PR extracts them.

- Introduce reusable stratum_timing_tracker_t in components/stratum with fixed 64 slots and O(1) ring-buffer indexing.
- Replace dynamic PSRAM allocation of 1000 RequestTiming structs in Stratum V1 with static tracker.
- Replace ad-hoc 32-slot timing array and manual latency calculation in Stratum V2 with unified tracker.
- Add unit tests for timing tracker in components/stratum/test/test_stratum_timing.c.
@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Test Results

  2 files  ±0    2 suites  ±0   2s ⏱️ ±0s
259 tests +4  259 ✅ +4  0 💤 ±0  0 ❌ ±0 
261 runs  +4  261 ✅ +4  0 💤 ±0  0 ❌ ±0 

Results for commit f0a02b2. ± Comparison against base commit 53283ac.

♻️ This comment has been updated with latest results.

@mutatrum mutatrum changed the title refactor(stratum): unify share latency timing tracker across protocols Extract share latency timing tracker out of sv1 and sv2 Oct 3, 2026
…stratum-timing

# Conflicts:
#	main/tasks/stratum_v1_client.c
#	main/tasks/stratum_v2_client.c

@johnny9 johnny9 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The four tracker tests reach 100% helper branch coverage, but the test suite does not compile either client. Add client tests for failed sends, V2 batch replies, reconnect resets, and the two regressions below.

Comment thread components/stratum/include/stratum_timing.h
Comment thread main/tasks/stratum_v1_client.c Outdated
@0xf0xx0 0xf0xx0 added the enhancement New feature or request label Oct 8, 2026
@mutatrum

mutatrum commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator Author

The four tracker tests reach 100% helper branch coverage, but the test suite does not compile either client. Add client tests for failed sends, V2 batch replies, reconnect resets, and the two regressions below.

The clients are in main, and fall outside the scope of unity tests. To properly do this, we should move all code out of main into components and only leave a thin main. Before trying to get more coverage on that code, it would make sense to componentize the parts we want tested, but that is outside the scope of this PR.

Comment thread main/tasks/stratum_v1_client.c Outdated
Comment thread main/tasks/stratum_task.c Outdated
…stratum-timing

# Conflicts:
#	main/tasks/stratum_v2_client.c
- Track V1 configure and subscribe message IDs in is_setup_msg to prevent
  failed setup replies from incrementing rejected share metrics
- Record submitted shares and reset pool sessions under transport_mutex to
  prevent disconnects from creating phantom pending shares
- Protect V1 runtime socket writes and narrow V2 connection teardown lock
…stratum-timing

# Conflicts:
#	main/tasks/stratum_v1_client.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants